package com.example.function.integration.config;

import lombok.Data;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.PropertySource;
import org.springframework.stereotype.Component;

/**
 * @description: 公共资源配置
 * @className:CommonConfig
 * @author:ext.fengcheng
 * @date:2023/9/15 14:42
 */
@Data
@Component
@PropertySource("classpath:application.properties")
public class CommonResourceConfig {

    /**
     * 加解密类型
     */
    public static String morseCryptoType;
    /**
     * 加解密秘钥
     */
    public static String morseCryptoSecretKey;
    /**
     * 邮箱服务器地址
     */
    @Value("${email.host}")
    private String emailHost;
    /**
     * 邮箱账号
     */
    @Value("${email.username}")
    private String emailUserName;
    /**
     * 邮箱密码
     */
    @Value("${email.password}")
    private String emailPassword;
    /**
     * 是否进行邮箱身份认证
     */
    @Value("${email.smtp.auth}")
    private String emailSmtpAuth;
    /**
     * 是否启用TLS加密通道
     */
    @Value("${email.smtp.starttls.enable}")
    private String emailSmtpStarttlsEnable;

    @Value("${morse.crypto.type}")
    public void setMorseCryptoType(String morseCryptoType) {
        CommonResourceConfig.morseCryptoType = morseCryptoType;
    }

    @Value("${morse.crypto.secretKey}")
    public void setMorseCryptoSecretKey(String morseCryptoSecretKey) {
        CommonResourceConfig.morseCryptoSecretKey = morseCryptoSecretKey;
    }

}
